package com.asiainfo.dacp.datastash.broker.listener;

import java.util.Date;

/**
 * 抽象队列的监听器
 *
 * @author MeiKefu
 * @date 2017-11-23
 */
public abstract class AbstractQueueListener implements Runnable {

    public void run(){
        // 这里可以用阻塞的MQ，也可以使用死循环完成非阻塞
        while(isRunning()){
            handle();
            try {
                Thread.sleep(getIntervals()*1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    protected abstract void handle();

    protected int getIntervals(){
        return 15;
    }
    
    protected boolean isRunning(){
    	return true;
    }
}
